
# put your PETSC_xxx values here
PETSC_DIR=$(shell $(HOME)/bin/petscdir)
PETSC_ARCH=$(shell $(HOME)/bin/petscarch)

# put installation directory for soah3d executable here:
SOAH3D_INSTALL_DIR=$(HOME)/bin

# only modify the following if something is wrong, okay!
# ============================================================================


base_dir := ..
LIBFILE=$(base_dir)/../lib/libcommon.a
include $(base_dir)/errlog/Makefile.vars

# default target -- runs when no target is specified
all :: $(LIBFILE)
	
include $(base_dir)/errlog/Makefile.rulz

# this imports the PETSC makefile rules.
include $(PETSC_DIR)/conf/base

# this file is automatically generated and contains dependency info
include Makefile.d

# this is used by petcs
LOCDIR=$(shell pwd)

# hold-all include variable
ALL_INCLUDES = -I. -I.. -I$(ERRLOG_DIR)

# use these flags with gcc
DEPGENFLAGS = -MM $(ALL_INCLUDES)
CFLAGS = -m64 -g -std=c99 $(ALL_INCLUDES)
CXXFLAGS = -m64 -g $(ALL_INCLUDES)
# LDFLAGS = -m64 -lm $(LINK_MESQUITE)
 
# use these flags with suncc
# DEPGENFLAGS = -xM1 $(INCLUDE_MESQUITE)
# CFLAGS = -m64 -xc99 -errfmt=error $(INCLUDE_MESQUITE)
# LDFLAGS = -m64 -lm $(LINK_MESQUITE) 

# the source files are all *.c files in the current directory.
# if you have any .c files that are not part of the project, put them in 
# a subdirectory.  Otherwise a compilation error in one of them ruin all.
# srcc = $(shell ls $(MY_SRCDIR)/*.c)
srcc = $(shell ls *.c)
# srccc = $(shell ls *.cc)

# every .c file produces a .o file with the same name, so
objs = $(srcc:.c=.o) # $(srccc:.cc=.o)

# this creates the library
$(LIBFILE) : $(objs) $(ERRLOG_LIB)
		${AR} rcs $@ $?

# this compiles all sources without linking
compile : $(objs) chkopts
	
	
# this removes the executable and all .o object files
.PHONY : clean
clean ::
	-@${RM} $(objs) $(LIBFILE)

# this generates dependency info
Makefile.d : $(srcc) # $(srccc)
	$(CC) $(DEPGENFLAGS) $^ > Makefile.d


